#!/bin/bash
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source $DIR/environment

if [ $# -lt 2 ]
  then
    echo "You should provide at least 2 args: path and package"
    exit 1
fi

PACKAGE_PATH=$1
PACKAGE_EGG=$2

$DIR/check
if [ $? -eq 0 ]; then
    docker-compose run -w /polyaxon/${PACKAGE_PATH} --rm --name=polyaxon_manage web /bin/bash -c "python3 setup.py bdist_wheel && rm -rf "${PACKAGE_EGG}.egg-info" && rm -rf build"
    docker-compose run --rm --name=polyaxon_manage web mv ${PACKAGE_PATH}/dist/* pydist/
fi
